﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileTasks
{
    class Program
    {
        static void Main(string[] args)
        {

            //Create folder
            string newDir = @"C:\Users\anton\Documents\C#\Inteducation\aisaiev\FileTasks\FileTasks\Test2";
            Directory.CreateDirectory(newDir);

            //Copy files
            string[] files = Directory.GetFiles(@"C:\Users\anton\Documents\C#\Inteducation\aisaiev\FileTasks\FileTasks\Test", "*.txt", SearchOption.TopDirectoryOnly);

            if (Directory.Exists(newDir))
            {
                foreach (var file in files)
                {
                    Console.WriteLine(file);
                    string file2 = file.Replace("Test", "Test2");
                    File.Copy(file, file2);
                }
            }

            //Delete folder
            bool isDirectoryExist = Directory.Exists(@"C:\Users\anton\Documents\C#\Inteducation\aisaiev\FileTasks\FileTasks\Test");

            if (isDirectoryExist)
            {
                Directory.Delete(@"C:\Users\anton\Documents\C#\Inteducation\aisaiev\FileTasks\FileTasks\Test", true);
            }

            //Print some text in txt files
            string text = "Some text";
            string[] files2 = Directory.GetFiles(newDir, "*.txt", SearchOption.TopDirectoryOnly);
            foreach(var file in files2)
            {
                File.WriteAllText(file, text);
            }
        }
    }
}
